package com.lrkj.waitress.controller;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.waitress.domain.JoinFile;
import com.lrkj.waitress.service.IJoinFileService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 入伙材料Controller
 *
 * @author yajun_ren
 * @date 2022-03-18
 */
@RestController
@RequestMapping("/waitress/joinFile")
@Api(tags = "入伙材料")
public class JoinFileController extends BaseController
{
    @Autowired
    private IJoinFileService joinFileService;

    /**
     * 查询入伙材料列表
     */
    @ApiOperation(value = "查询入伙材料列表", notes = "查询入伙材料列表")
    @PreAuthorize("@ss.hasPermi('waitress:joinFile:list')")
    @GetMapping("/list")
    public TableDataInfo list(JoinFile joinFile)
    {
        startPage();
        this.changeParameter(joinFile.getParams());
        List<JoinFile> list = joinFileService.selectJoinFileList(joinFile);
        return getDataTable(list);
    }

    /**
     * 获取入伙材料详细信息
     */
	@ApiOperation(value = "获取入伙材料详细信息", notes = "获取入伙材料详细信息")
    @PreAuthorize("@ss.hasPermi('waitress:joinFile:query')")
    @GetMapping(value = "/{fileId}")
    public AjaxResult getInfo(@PathVariable("fileId") String fileId)
    {
        return AjaxResult.success(joinFileService.selectJoinFileById(fileId));
    }

    /**
     * 新增入伙材料
     */
    @ApiOperation(value = "新增入伙材料", notes = "新增入伙材料")
    @PreAuthorize("@ss.hasPermi('waitress:joinFile:add')")
    @Log(title = "入伙材料", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JoinFile joinFile)
    {
        return toAjax(joinFileService.insertJoinFile(joinFile));
    }

    /**
     * 修改入伙材料
     */
    @ApiOperation(value = "修改入伙材料", notes = "修改入伙材料")
    @PreAuthorize("@ss.hasPermi('waitress:joinFile:edit')")
    @Log(title = "入伙材料", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JoinFile joinFile)
    {
        return toAjax(joinFileService.updateJoinFile(joinFile));
    }

    /**
     * 删除入伙材料
     */
    @ApiOperation(value = "删除入伙材料", notes = "删除入伙材料")
    @PreAuthorize("@ss.hasPermi('waitress:joinFile:remove')")
    @Log(title = "入伙材料", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fileIds}")
    public AjaxResult remove(@PathVariable String[] fileIds)
    {
        return toAjax(joinFileService.deleteJoinFileByIds(fileIds));
    }
}
